<?php namespace App\Exceptions;

use Exception;

class SignInException extends Exception
{
    const UserNameNotExists = 0x01;
    const PhoneNotExists = 0x02;
    const EmailNotExists = 0x03;
    const PasswordNotMatch = 0x04;
    const IllegalUsername = 0x05;
    const PasswordRuleError = 0x06;
    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::EmailNotExists:
                $message = trans('邮箱未注册！');
                break;
            case self::PasswordNotMatch:
                $message = trans('密码错误！');
                break;
            case self::UserNameNotExists:
                $message = trans('用户名不存在！');
                break;
            case self::PhoneNotExists:
                $message = trans('手机号不存在！');
                break;
            case self::IllegalUsername:
                $message = trans('非法用户名,只能含有下划线！');
                break;
            case self::PasswordRuleError:
                $message = trans('密码长度在6-16位间');
                break;

            default:
                $message = trans('未知错误');
                break;
        }

        parent::__construct($message, $code, $previous);
    }

}